package com.penghaisoft.microwms.product.web.controller.expose;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.penghaisoft.microwms.common.Constant;
import com.penghaisoft.microwms.common.controller.BaseController;
import com.penghaisoft.microwms.common.dto.HandResp;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.wms.model.ProOrderInSn;
import com.penghaisoft.microwms.product.service.IProOrderInSnService;

/**
 * @Description 成品下线入库明细表
 * @author luoteng
 * @date 2018年6月20日 下午2:22:10 
 * @version 1.0
 */
@RestController
@RequestMapping(value = "/expose/mes")
public class ProExposeMesController extends BaseController {


	@Autowired
	private IProOrderInSnService proOrderInSnService;
    
    /** 
     * @Title proOrderInSnAdd
     * @Description 成品下线入库明细表 新增
     * @author luoteng
     * @date 2018年6月20日:下午2:23:02
     * @param list
     * @return HandResp
     */
    @PostMapping("proorderinsn/add")
    public HandResp proOrderInSnAdd(@RequestBody List<ProOrderInSn> list) {
        HandResp result = new HandResp();
        try{
        	List<ProOrderInSn> checkList = proOrderInSnService.mesBatchInsertOrderInSnCheck(list);
        	if(checkList != null && !checkList.isEmpty()){
        		result.setCode(Constant.FAIL);
                result.setMsg("校验不通过！");
                result.setList(checkList);
        	}else{
        		Resp resp = proOrderInSnService.mesBatchInsertOrderInSn(list);
                result.setCode(resp.getCode());
                result.setMsg(resp.getMsg());
        	}
        }catch(RuntimeException e){
        	result.setCode(Constant.FAIL);
            result.setMsg(e.getMessage());
            e.printStackTrace();
//            rawRequisitionService.batchNormalHisInsert(list, e.getMessage());
        }
        
        return result;
    }
}
